package com.example.administrator.myapplication.util;

import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * Created by Administrator on 2020/12/7.
 */

public class MyHelper extends SQLiteOpenHelper {
    public MyHelper(Context context) {
        super(context,"HEYING", null, 1);
    }

    @Override
    public void onCreate(SQLiteDatabase sqLiteDatabase) {
        sqLiteDatabase.execSQL("create table acount(id integer primary key autoincrement," +
                "username varchar(20)not null,student_id varchar(20)not null)");
    }

    @Override
    public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {

    }
    public void insert(Context context,String username,String student_id){
         MyHelper myHelper = new MyHelper(context);
         SQLiteDatabase db = myHelper.getWritableDatabase();
        ContentValues values =new ContentValues();
        values.put("username",username);
        values.put("student_id",student_id);
          long id =db.insert("acount",null,values);
            db.close();
    }

}
